package com.hzhr.iot.device.convertor;

import com.hzhr.iot.device.convertor.custom.*;
import com.hzhr.iot.core.util.HzhrTypeUtil;
import com.hzhr.iot.core.util.HzhrJsonUtil;
import java.util.Map;
import com.hzhr.iot.device.model.iotDeviceType.IotDeviceTypeModel;
import com.hzhr.iot.device.entity.IotDeviceTypeEntity;
import com.hzhr.iot.device.entity.ext.IotDeviceTypeEntityExt;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import com.hzhr.iot.device.model.iotDeviceType.IotDeviceTypeModel;
import com.hzhr.iot.device.model.iotDeviceType.IotDeviceTypeGetModel;
import com.hzhr.iot.device.model.iotDeviceType_des.IotDeviceType_DesModel;
import com.hzhr.iot.device.model.iotDeviceType_des.IotDeviceType_DesGetModel;
import com.hzhr.iot.device.queryModel.custom.IotDeviceTypeCustomQueryModel;

@Component
public class IotDeviceTypeConvertor {
    @Autowired
    AlarmDataCustomConvertor alarmDataCustomConvertor;
    @Autowired
    CollectDataCustomConvertor collectDataCustomConvertor;
    @Autowired
    CollectDeviceCustomConvertor collectDeviceCustomConvertor;
    @Autowired
    CollectDeviceTypeCustomConvertor collectDeviceTypeCustomConvertor;
    @Autowired
    DeviceInfoCardCustomConvertor deviceInfoCardCustomConvertor;
    @Autowired
    DeviceMaintenanceCardCustomConvertor deviceMaintenanceCardCustomConvertor;
    @Autowired
    DeviceMaintenanceCardItemCustomConvertor deviceMaintenanceCardItemCustomConvertor;
    @Autowired
    ImplFactoryCustomConvertor implFactoryCustomConvertor;
    @Autowired
    ImplIotDeviceTypeCustomConvertor implIotDeviceTypeCustomConvertor;
    @Autowired
    ImplRecordCustomConvertor implRecordCustomConvertor;
    @Autowired
    IotDeviceCustomConvertor iotDeviceCustomConvertor;
    @Autowired
    OptionsCustomConvertor optionsCustomConvertor;
    @Autowired
    ProdFactoryCustomConvertor prodFactoryCustomConvertor;
    @Autowired
    RegulatorCollectDataCustomConvertor regulatorCollectDataCustomConvertor;
    @Autowired
    UserCompanyCustomConvertor userCompanyCustomConvertor;

    public IotDeviceTypeEntity iotDeviceTypeModel2entity(IotDeviceTypeModel in) {
        //未转换字段: createUserId createTime updateUserId isValid outId updateTime state 
        if (in == null) return null;
        IotDeviceTypeEntity result = new IotDeviceTypeEntity();

        result.setId(HzhrTypeUtil.integer2integer(in.getId()));
        result.setDes(HzhrTypeUtil.string2string(in.getDes()));
        result.setCompanyId(HzhrTypeUtil.integer2integer(in.getCompanyId()));
        result.setDeviceCategoryCode(HzhrTypeUtil.string2string(in.getDeviceCategoryCode()));
        return result;
    }
    public IotDeviceTypeEntity iotDeviceTypeModel2entity(IotDeviceTypeModel in, IotDeviceTypeEntity ori) {
        //未转换字段: createUserId createTime updateUserId isValid outId updateTime state 
        if (in == null) return null;
        IotDeviceTypeEntity result = ori;

        result.setId(HzhrTypeUtil.integer2integer(in.getId()));
        result.setDes(HzhrTypeUtil.string2string(in.getDes()));
        result.setCompanyId(HzhrTypeUtil.integer2integer(in.getCompanyId()));
        result.setDeviceCategoryCode(HzhrTypeUtil.string2string(in.getDeviceCategoryCode()));
        return result;
    }
    public List<IotDeviceTypeEntity> iotDeviceTypeModelList2entityList(List<IotDeviceTypeModel> in) {
        if (in == null) return null;
        List<IotDeviceTypeEntity> result = new ArrayList<>();
        for (IotDeviceTypeModel item : in) {
            result.add(iotDeviceTypeModel2entity(item));
        }
        return result;
    }
    public IotDeviceTypeModel entity2iotDeviceTypeModel(IotDeviceTypeEntity in) {
        //未转换字段: 
        if (in == null) return null;
        IotDeviceTypeModel result = new IotDeviceTypeModel();

        result.setId(HzhrTypeUtil.integer2integer(in.getId()));
        result.setDes(HzhrTypeUtil.string2string(in.getDes()));
        result.setCompanyId(HzhrTypeUtil.integer2integer(in.getCompanyId()));
        result.setDeviceCategoryCode(HzhrTypeUtil.string2string(in.getDeviceCategoryCode()));
        return result;
    }
    public List<IotDeviceTypeModel> entityList2iotDeviceTypeModelList(List<IotDeviceTypeEntity> in) {
        if (in == null) return null;
        List<IotDeviceTypeModel> result = new ArrayList<>();
        for (IotDeviceTypeEntity item : in) {
            result.add(entity2iotDeviceTypeModel(item));
        }
        return result;
    }
    public IotDeviceTypeModel ext2iotDeviceTypeModel(IotDeviceTypeEntityExt in) {
        //未转换字段: 
        if (in == null) return null;
        IotDeviceTypeModel result = new IotDeviceTypeModel();

        result.setId(HzhrTypeUtil.integer2integer(in.getId()));
        result.setDes(HzhrTypeUtil.string2string(in.getDes()));
        result.setCompanyId(HzhrTypeUtil.integer2integer(in.getCompanyId()));
        result.setDeviceCategoryCode(HzhrTypeUtil.string2string(in.getDeviceCategoryCode()));
        return result;
    }
    public List<IotDeviceTypeModel> extList2iotDeviceTypeModelList(List<IotDeviceTypeEntityExt> in) {
        if (in == null) return null;
        List<IotDeviceTypeModel> result = new ArrayList<>();
        for (IotDeviceTypeEntityExt item : in) {
            result.add(ext2iotDeviceTypeModel(item));
        }
        return result;
    }
    public IotDeviceTypeGetModel extList2iotDeviceTypeGetModel(List<IotDeviceTypeEntityExt> extList, Integer total, Integer changeCount, Map<String, Object> query) {
        List<IotDeviceTypeModel> modelList = extList2iotDeviceTypeModelList(extList);
        if (modelList == null) {
            IotDeviceTypeGetModel result = new IotDeviceTypeGetModel();
            result.setTotal(total);
            result.setChangeCount(changeCount);
            return result;
        }

         String _show = HzhrTypeUtil.object2string(query.get("_show"));
         Boolean _show_info = query.get("_show_info") != null ? Boolean.parseBoolean(query.get("_show_info").toString()) : false;

        if (!_show_info) {
            for (IotDeviceTypeModel model : modelList) {
                model.setDes(null);
                model.setCompanyId(null);
                model.setDeviceCategoryCode(null);
            }
        }

        IotDeviceTypeGetModel result = new IotDeviceTypeGetModel();
        if ("one".equals(_show)) {
            if (modelList.size() > 0) {
                result.setModel(modelList.get(0));
            }
         }
        if ("list".equals(_show)) {
            result.setModelList(modelList);
        }
        result.setTotal(total);
        result.setChangeCount(changeCount);
        return result;
    }
    public IotDeviceTypeGetModel entity2iotDeviceTypeGetModel(IotDeviceTypeEntity entity, Integer total, Integer changeCount, Map<String, Object> query) {
        List<IotDeviceTypeEntityExt> extList = new ArrayList<>();
        if (entity == null) return extList2iotDeviceTypeGetModel(extList, total, changeCount, query);
        extList.add(HzhrJsonUtil.convertObjectType(entity, IotDeviceTypeEntityExt.class));
        return extList2iotDeviceTypeGetModel(extList, total, changeCount, query);
     }
    public IotDeviceTypeEntity iotDeviceType_DesModel2entity(IotDeviceType_DesModel in) {
        //未转换字段: companyId createUserId createTime updateUserId isValid outId updateTime state deviceCategoryCode 
        if (in == null) return null;
        IotDeviceTypeEntity result = new IotDeviceTypeEntity();

        result.setId(HzhrTypeUtil.integer2integer(in.getId()));
        result.setDes(HzhrTypeUtil.string2string(in.getDes()));
        return result;
    }
    public IotDeviceTypeEntity iotDeviceType_DesModel2entity(IotDeviceType_DesModel in, IotDeviceTypeEntity ori) {
        //未转换字段: companyId createUserId createTime updateUserId isValid outId updateTime state deviceCategoryCode 
        if (in == null) return null;
        IotDeviceTypeEntity result = ori;

        result.setId(HzhrTypeUtil.integer2integer(in.getId()));
        result.setDes(HzhrTypeUtil.string2string(in.getDes()));
        return result;
    }
    public List<IotDeviceTypeEntity> iotDeviceType_DesModelList2entityList(List<IotDeviceType_DesModel> in) {
        if (in == null) return null;
        List<IotDeviceTypeEntity> result = new ArrayList<>();
        for (IotDeviceType_DesModel item : in) {
            result.add(iotDeviceType_DesModel2entity(item));
        }
        return result;
    }
    public IotDeviceType_DesModel entity2iotDeviceType_DesModel(IotDeviceTypeEntity in) {
        //未转换字段: 
        if (in == null) return null;
        IotDeviceType_DesModel result = new IotDeviceType_DesModel();

        result.setId(HzhrTypeUtil.integer2integer(in.getId()));
        result.setDes(HzhrTypeUtil.string2string(in.getDes()));
        return result;
    }
    public List<IotDeviceType_DesModel> entityList2iotDeviceType_DesModelList(List<IotDeviceTypeEntity> in) {
        if (in == null) return null;
        List<IotDeviceType_DesModel> result = new ArrayList<>();
        for (IotDeviceTypeEntity item : in) {
            result.add(entity2iotDeviceType_DesModel(item));
        }
        return result;
    }
    public IotDeviceType_DesModel ext2iotDeviceType_DesModel(IotDeviceTypeEntityExt in) {
        //未转换字段: 
        if (in == null) return null;
        IotDeviceType_DesModel result = new IotDeviceType_DesModel();

        result.setId(HzhrTypeUtil.integer2integer(in.getId()));
        result.setDes(HzhrTypeUtil.string2string(in.getDes()));
        return result;
    }
    public List<IotDeviceType_DesModel> extList2iotDeviceType_DesModelList(List<IotDeviceTypeEntityExt> in) {
        if (in == null) return null;
        List<IotDeviceType_DesModel> result = new ArrayList<>();
        for (IotDeviceTypeEntityExt item : in) {
            result.add(ext2iotDeviceType_DesModel(item));
        }
        return result;
    }
    public IotDeviceType_DesGetModel extList2iotDeviceType_DesGetModel(List<IotDeviceTypeEntityExt> extList, Integer total, Integer changeCount, Map<String, Object> query) {
        List<IotDeviceType_DesModel> modelList = extList2iotDeviceType_DesModelList(extList);
        if (modelList == null) {
            IotDeviceType_DesGetModel result = new IotDeviceType_DesGetModel();
            result.setTotal(total);
            result.setChangeCount(changeCount);
            return result;
        }

         String _show = HzhrTypeUtil.object2string(query.get("_show"));
         Boolean _show_info = query.get("_show_info") != null ? Boolean.parseBoolean(query.get("_show_info").toString()) : false;

        if (!_show_info) {
            for (IotDeviceType_DesModel model : modelList) {
                model.setDes(null);
            }
        }

        IotDeviceType_DesGetModel result = new IotDeviceType_DesGetModel();
        if ("one".equals(_show)) {
            if (modelList.size() > 0) {
                result.setModel(modelList.get(0));
            }
         }
        if ("list".equals(_show)) {
            result.setModelList(modelList);
        }
        result.setTotal(total);
        result.setChangeCount(changeCount);
        return result;
    }
    public IotDeviceType_DesGetModel entity2iotDeviceType_DesGetModel(IotDeviceTypeEntity entity, Integer total, Integer changeCount, Map<String, Object> query) {
        List<IotDeviceTypeEntityExt> extList = new ArrayList<>();
        if (entity == null) return extList2iotDeviceType_DesGetModel(extList, total, changeCount, query);
        extList.add(HzhrJsonUtil.convertObjectType(entity, IotDeviceTypeEntityExt.class));
        return extList2iotDeviceType_DesGetModel(extList, total, changeCount, query);
     }
    public IotDeviceTypeCustomQueryModel iotDeviceTypeService_query2queryModel(Map<String, Object> query) {
        IotDeviceTypeCustomQueryModel queryModel = new IotDeviceTypeCustomQueryModel();

        Integer _equal_id = HzhrTypeUtil.object2integer(query.get("_equal_id"));
        if (_equal_id != null) {
            queryModel.setEqual_id(_equal_id);
         }

        Integer _equal_companyId = HzhrTypeUtil.object2integer(query.get("_equal_companyId"));
        if (_equal_companyId != null) {
            queryModel.setEqual_companyId(_equal_companyId);
         }

        String _equal_deviceCategoryCode = HzhrTypeUtil.object2string(query.get("_equal_deviceCategoryCode"));
        if (_equal_deviceCategoryCode != null) {
            queryModel.setEqual_deviceCategoryCode(_equal_deviceCategoryCode);
         }

        Boolean _show_info = HzhrTypeUtil.object2boolean(query.get("_show_info"));
        if (_show_info != null && _show_info) {
            queryModel.setShow(true);
            queryModel.setShow(true);
            queryModel.setShow(true);
        }

        Integer page = HzhrTypeUtil.object2integer(query.get("_page"));
        Integer count = HzhrTypeUtil.object2integer(query.get("_count"));
        queryModel.setPage(page, count);

        return queryModel;
    }
    public IotDeviceTypeCustomQueryModel iotDeviceType_DesService_query2queryModel(Map<String, Object> query) {
        IotDeviceTypeCustomQueryModel queryModel = new IotDeviceTypeCustomQueryModel();

        Integer _equal_id = HzhrTypeUtil.object2integer(query.get("_equal_id"));
        if (_equal_id != null) {
            queryModel.setEqual_id(_equal_id);
         }

        Integer _equal_companyId = HzhrTypeUtil.object2integer(query.get("_equal_companyId"));
        if (_equal_companyId != null) {
            queryModel.setEqual_companyId(_equal_companyId);
         }

        String _equal_deviceCategoryCode = HzhrTypeUtil.object2string(query.get("_equal_deviceCategoryCode"));
        if (_equal_deviceCategoryCode != null) {
            queryModel.setEqual_deviceCategoryCode(_equal_deviceCategoryCode);
         }

        Boolean _show_info = HzhrTypeUtil.object2boolean(query.get("_show_info"));
        if (_show_info != null && _show_info) {
            queryModel.setShow(true);
            queryModel.setShow(true);
            queryModel.setShow(true);
        }

        Integer page = HzhrTypeUtil.object2integer(query.get("_page"));
        Integer count = HzhrTypeUtil.object2integer(query.get("_count"));
        queryModel.setPage(page, count);

        return queryModel;
    }

}

